package com.zz.common.config;

import com.zz.common.entity.Meta;
import com.zz.common.enums.AttrKey;
import com.zz.common.function.Callback;
import com.zz.common.protocol.TunnelProtocol;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

import java.util.Map;
import java.util.regex.Pattern;

/**
 * 常量池
 */
public interface Constants {

    // channel 自定义常量池
    interface Attributes {
        public static final AttributeKey<Channel> SERVER_CHANNEL = AttributeKey.newInstance(AttrKey.SERVER_CHANNEL.getKey());
        public static final AttributeKey<Channel> LOCAL_CHANNEL = AttributeKey.newInstance(AttrKey.CLIENT_CHANNEL.getKey());
        public static final AttributeKey<Map<String, Channel>> CHANNEL_CACHE = AttributeKey.newInstance(AttrKey.CHANNEL_CACHE.getKey());
        public static final AttributeKey<Meta> META = AttributeKey.newInstance(AttrKey.META.getKey());

    }


    // string 自定义常量池
    interface Strings {
        public final static String EMPTY_STR = "";

        public final static String SUCCESS = "success";

        public final static String FAIL = "fail";

        public final static String PROTOCOL_TYPE = "config.protocol";

        public final static String DATA_SOURCE = "config.dataSource";
        public final static String DEFAULT_SOURCE = "default";

        public final static String NULL = null;
    }

    // 数字自定义常量池
    interface Numbers {
        public final static byte HEADER_SIZE = 4;

        public final static byte META_SIZE = 4;

        public final static int TYPE_SIZE = 1;

        public final static int SERIAL_NUMBER_SIZE = 8;

        public final static int HEADER_LENGTH_SIZE = 1;

        public final static int SERIALIZE_SIDE = 1;

        public final static byte ZERO = 0x00;
    }


    // 对象自定义常量池
    interface Objects {
        public final static Object NULL = null;
        public final static Map<String, Channel> MAP_NULL = null;
        public final static Channel CHANNEL_NULL = null;
        public final static TunnelProtocol NULL_PROTOCOL = null;
        Pattern COLON = Pattern.compile(":");

        Pattern BLANK = Pattern.compile("\\s");
    }



}
